package cn.yx.common.core.util.image;

import cn.yx.common.core.util.RandomUtil;

import java.awt.*;

/**
 * <p>颜色工具类</p>
 *
 * @author Wgssmart
 */
public final class ColorUtil {

    private ColorUtil() {
    }

    public static final Color[] BACKGROUND_COLORS = {
            new Color(0, 102, 153),
            new Color(0, 153, 153),
            new Color(0, 204, 153),
            new Color(0, 255, 153),
            new Color(51, 0, 153),
            new Color(51, 51, 153),
            new Color(51, 102, 153),
            new Color(51, 153, 153),
            new Color(51, 204, 153),
            new Color(51, 255, 153),
            new Color(102, 0, 153),
            new Color(102, 51, 153),
            new Color(102, 102, 153),
            new Color(102, 153, 153),
            new Color(102, 204, 153),
            new Color(102, 255, 153),
            new Color(153, 0, 153),
            new Color(153, 51, 153),
            new Color(153, 102, 153),
            new Color(153, 153, 153),
            new Color(153, 204, 153),
            new Color(153, 255, 153),
            new Color(204, 0, 153),
            new Color(204, 51, 153),
            new Color(204, 102, 153),
            new Color(204, 153, 153),
            new Color(204, 204, 153),
            new Color(204, 255, 153),
            new Color(255, 0, 153),
            new Color(255, 51, 153),
            new Color(255, 102, 153),
            new Color(255, 153, 153),
            new Color(255, 204, 153),
            new Color(255, 255, 153),
    };

    /**
     * 生成随机颜色
     *
     * @return
     */
    public static Color randomColor() {
        return new Color(RandomUtil.randomInt(0, 256), RandomUtil.randomInt(0, 256), RandomUtil.randomInt(0, 256));
    }

    /**
     * 随机获取BACKGROUND_COLORS中定义的背景色
     *
     * @return
     */
    public static Color backgroundColor() {
        return BACKGROUND_COLORS[RandomUtil.randomInt(0, BACKGROUND_COLORS.length)];
    }

}
